<?php

use p5\objects\MemcacheUtils;

function mem_stats($flag)
{
    return MemcacheUtils::stats($flag);
}

/**
 * @param $key
 * @param $object
 * @param bool $compress
 * @param int $timeLong 当前写入缓存的数据的失效时间。如果此值设置为0表明此数据永不过期。
 * 你可以设置一个UNIX时间戳或 以秒为单位的整数（从当前算起的时间差）来说明此数据的过期时间，
 * 但是在后一种设置方式中，不能超过 2592000秒（30天）。
 */
function mem_cache($key, $object, $compress = false, $timeLong = 0)
{
    MemcacheUtils::cache($key, $object, $compress, $timeLong);
}

function mem_replace($key, $object, $compress = false, $timeLong = 0)
{
    MemcacheUtils::replace($key, $object, $compress, $timeLong);
}

function mem_exists($key)
{
    return MemcacheUtils::exists($key);
}

function mem_get($key, $obj = false, $compress = false, $timeLong = 0)
{
    return MemcacheUtils::get($key, $obj, $compress, $timeLong);
}

function mem_delete($key, $delay = 0)
{
    return MemcacheUtils::delete($key, $delay);
}

function mem_flush()
{
    return MemcacheUtils::flush();
}

function mem_get_sql_result($sqlstr, $compress = 0, $timeLong = 0, $db_id = "default")
{
    return MemcacheUtils::get_sql_result($sqlstr, $compress, $timeLong, $db_id);
}

//直接在MEM里存储单数据 后续完善跨不同数据库下的MEM存储
function mem_get_col00_result($sqlstr, $compress = 0, $timeLong = 0, $db_id = "default")
{
    return MemcacheUtils::get_col00_result($sqlstr, $compress, $timeLong, $db_id);
}

function mem_map_get_result($sqlstr, $compress = 0, $timeLong = 0, $db_id = "default")
{
    return MemcacheUtils::map_get_result($sqlstr, $compress, $timeLong, $db_id);
}

function mem_map_get($sqlstr, $compress = 0, $timeLong = 120, $db_id = "default")
{
    return MemcacheUtils::map_get($sqlstr, $compress, $timeLong, $db_id);
}

function mem_auto_add($key, $object, $compress, $timeLong)
{
    return MemcacheUtils::increment($key, $object, $compress, $timeLong);
}
